﻿@namespace MudBlazor.UnitTests.TestComponents

@using MudBlazor.Utilities

<MudPopoverProvider>

</MudPopoverProvider>

<MudColorPicker @ref="_picker" @bind-Value="ColorValue" TextChanged="@((x) => { TextValue = x; ValueChangeCallbackCounter++;  })" Palette="Palette" 
                DisableToolbar="DisableToolbar" 
                DisableColorField="DisableColorField" 
                DisablePreview="DisablePreview" 
                DisableSliders="DisableSliders"
                DisableInputs="DisableInput"
                DisableModeSwitch="DisableModeSwitch"
                DisableAlpha="DisableAlpha"
                ColorPickerView="@ViewMode"
                AlwaysUpdateBinding="AlwaysUpdateBinding"
                ColorPickerMode="ColorPickerMode" PickerVariant="Variant" />

@code {
    private MudColorPicker _picker;

    public Int32 ValueChangeCallbackCounter { get; private set; } = 0;

    [Parameter] public MudColor ColorValue { get; set; } = "#594ae2";
    [Parameter] public string TextValue { get; set; } = "#594ae2";

    [Parameter] public IEnumerable<MudColor> Palette { get; set; } = new MudColor[] { "#ff4081ff", "#2196f3ff", "#00c853ff", "#ff9800ff", "#f44336ff" };

    [Parameter] public ColorPickerMode ColorPickerMode { get; set; } = ColorPickerMode.RGB;
    [Parameter] public bool DisableToolbar { get; set; } = true;
    [Parameter] public bool DisableColorField { get; set; } = false;
    [Parameter] public bool DisablePreview { get; set; } = false;
    [Parameter] public bool DisableSliders { get; set; } = false;
    [Parameter] public bool DisableInput { get; set; } = false;
    [Parameter] public bool DisableModeSwitch { get; set; } = false;
    [Parameter] public bool DisableAlpha { get; set; } = false;
    [Parameter] public ColorPickerView ViewMode { get; set; } = ColorPickerView.Spectrum;
    [Parameter] public PickerVariant Variant { get; set; } = PickerVariant.Static;
    [Parameter] public bool AlwaysUpdateBinding { get; set; } = false;

    public async Task OpenPicker()
    {
        await InvokeAsync(() =>
        {
            _picker.Open();
        });
    }

    public async Task ClosePicker()
    {
        await InvokeAsync(() =>
        {
            _picker.Close();
        });
    }

}

